

#import "AppDelegate+Note.h"

NSString * const kUserDidLoginNotification  = @"App-LogIn";
NSString * const kUserDidLogoutNotification = @"App-LogOut";
NSString * const kUserDidDeniedNotification = @"App-Denied";
NSString * const kUserPasswordDidChangeNotification = @"App-PasswordDidChange";

@implementation AppDelegate (Note)

- (void)setupNotifications {
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    NSOperationQueue *queue = [NSOperationQueue mainQueue];
    [center addObserverForName:kUserDidLoginNotification object:nil queue:queue usingBlock:^(NSNotification * _Nonnull note) {
        if ([self respondsToSelector:@selector(userDidLogin:)]) {
            [self userDidLogin:note];
        }
    }];
    [center addObserverForName:kUserDidLogoutNotification object:nil queue:queue usingBlock:^(NSNotification * _Nonnull note) {
        if ([self respondsToSelector:@selector(userDidLogout:)]) {
            [self userDidLogout:note];
        }
    }];
    [center addObserverForName:kUserDidDeniedNotification object:nil queue:queue usingBlock:^(NSNotification * _Nonnull note) {
        if ([self respondsToSelector:@selector(userDidDenied:)]) {
            [self userDidDenied:note];
        }
    }];
    [center addObserverForName:kUserPasswordDidChangeNotification object:nil queue:queue usingBlock:^(NSNotification * _Nonnull note) {
        if ([self respondsToSelector:@selector(userPasswordDidChange:)]) {
            [self userPasswordDidChange:note];
        }
    }];
}

@end
